package o;

import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.IdRes;
import androidx.annotation.NonNull;
import com.huawei.hmf.annotation.ApiDefine;
import java.util.ArrayList;
import java.util.Iterator;

@ApiDefine(uri = dey.class)
public class dfd implements dey {
    private ArrayList<deu> ˋ = new ArrayList();
    private dew ॱ;

    public dfd(@NonNull dew o_dew) {
        this.ॱ = o_dew;
    }

    public void ˎ(@IdRes int i, @NonNull deu o_deu, Bundle bundle) {
        if (this.ॱ == null) {
            throw new IllegalArgumentException("the SegmentContainerCallback is null");
        } else if (o_deu == null) {
            throw new IllegalArgumentException("the Segment is null");
        } else if (this.ˋ.contains(o_deu)) {
            throw new IllegalArgumentException("the container layout has been added segment, please use [replace] method instead");
        } else {
            ViewGroup viewGroup = (ViewGroup) this.ॱ.ˊ(i);
            if (viewGroup == null) {
                throw new IllegalArgumentException("the container view can not been found by id:" + i);
            }
            o_deu.ॱ(bundle);
            o_deu.ʽ(i);
            this.ˋ.add(o_deu);
            View ˋॱ = o_deu.ˋॱ();
            o_deu.ˏ(ˋॱ);
            if (ˋॱ != null) {
                viewGroup.addView(ˋॱ);
            }
            if (this.ॱ.ʼ()) {
                o_deu.onResume();
            }
        }
    }

    public void ॱ(@NonNull deu o_deu) {
        if (this.ॱ == null) {
            throw new IllegalArgumentException("the SegmentContainerCallback is null");
        } else if (o_deu == null) {
            throw new IllegalArgumentException("the Segment is null");
        } else if (this.ˋ.contains(o_deu)) {
            ViewGroup viewGroup = (ViewGroup) this.ॱ.ˊ(o_deu.ˎˏ());
            if (viewGroup == null) {
                throw new IllegalArgumentException("the container view can not been found by id:" + o_deu.ˎˏ());
            }
            this.ˋ.remove(o_deu);
            if (o_deu.ˏˎ() != null) {
                viewGroup.removeView(o_deu.ˏˎ());
                o_deu.onStop();
            }
            o_deu.onDestroy();
        } else {
            throw new IllegalArgumentException("there is no segment in the container");
        }
    }

    public void ˋ(@IdRes int i, @NonNull deu o_deu, Bundle bundle) {
        deu o_deu2;
        Iterator it = this.ˋ.iterator();
        while (it.hasNext()) {
            o_deu2 = (deu) it.next();
            if (o_deu2 != null && o_deu2.ˎˏ() == i) {
                break;
            }
        }
        o_deu2 = null;
        if (o_deu2 != null) {
            ॱ(o_deu2);
        }
        ˎ(i, o_deu, bundle);
    }

    public void ˏ() {
        Iterator it = this.ˋ.iterator();
        while (it.hasNext()) {
            deu o_deu = (deu) it.next();
            if (o_deu != null) {
                o_deu.onDestroy();
            }
        }
    }

    public void ˎ() {
        Iterator it = this.ˋ.iterator();
        while (it.hasNext()) {
            deu o_deu = (deu) it.next();
            if (o_deu != null) {
                o_deu.onStop();
            }
        }
    }

    public void ॱ() {
        Iterator it = this.ˋ.iterator();
        while (it.hasNext()) {
            deu o_deu = (deu) it.next();
            if (o_deu != null) {
                o_deu.onResume();
            }
        }
    }

    public void ˊ() {
        Iterator it = this.ˋ.iterator();
        while (it.hasNext()) {
            deu o_deu = (deu) it.next();
            if (o_deu != null) {
                o_deu.A_();
            }
        }
    }
}
